<!-- XHTML 1.0 Strict -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<meta name="author" content="Rachid Touzani" />
<meta name="keywords" content=" css, dropdowns, dropdown menu, drop-down, menu, navigation, nav, horizontal, vertical left-to-right, vertical right-to-left, horizontal linear, horizontal upwards, cross browser, internet explorer, ie, firefox, safari, opera, browser, lwis" />
<meta name="description" content="Clean, standards-friendly, modular framework for dropdown menus" />
<link href="../css/dropdown.vertical.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../css/default.ultimate.css" media="screen" rel="stylesheet" type="text/css" />

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Fluid Dynamics Demo 1</title>
<link rel="stylesheet" type="text/css" href="../doxygen.css" />
<link rel="stylesheet" type="text/css" href="../tabs.css"  />
</head>

<body bgcolor="#FFFFFF" link="#FF0000" vlink="#FF00FF" alink="#FF00FF">
<p align="center"><a href="../index.html"><img src="../im/ofeli.gif" width="150" border="0"></a></p>

<center>
  <div id="cse" style="width: 60%;">Loading</div>
  <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  <script type="text/javascript"> 
     google.load('search', '1', {language : 'en', style : google.loader.themes.SHINY});
     google.setOnLoadCallback(function() {
        var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
        '012396140824982761142:-qrywxcfi_o', customSearchOptions);
        customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
        customSearchControl.draw('cse');
     }, true);
   </script>
   <style type="text/css">
     .gsc-control-cse {
     font-family: Verdana, sans-serif;
     border-color: #DAE0E5;
     background-color: #DAE0E5;
   }
   .gsc-control-cse .gsc-table-result { font-family: Verdana, sans-serif; }
   input.gsc-input { border-color: #B6BEC5; }
   input.gsc-search-button {
     border-color: #B6BEC5;
     background-color: #D0D1D4;
   }
   .gsc-tabHeader.gsc-tabhInactive {
     border-color: #999999;
     background-color: #EEEEEE;
   }
   .gsc-tabHeader.gsc-tabhActive {
     border-color: #999999;
     background-color: #999999;
   }
   .gsc-tabsArea { border-color: #999999; }
   .gsc-webResult.gsc-result,
   .gsc-results .gsc-imageResult {
     border-color: #FFFFFF;
     background-color: #FFFFFF;
   }
   .gsc-webResult.gsc-result:hover,
   .gsc-imageResult:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gsc-webResult.gsc-result.gsc-promotion:hover {
     border-color: #D2D6DC;
     background-color: #EDEDED;
   }
   .gs-webResult.gs-result a.gs-title:link,
   .gs-webResult.gs-result a.gs-title:link b,
   .gs-imageResult a.gs-title:link,
   .gs-imageResult a.gs-title:link b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:visited,
   .gs-webResult.gs-result a.gs-title:visited b,
   .gs-imageResult a.gs-title:visited,
   .gs-imageResult a.gs-title:visited b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:hover,
   .gs-webResult.gs-result a.gs-title:hover b,
   .gs-imageResult a.gs-title:hover,
   .gs-imageResult a.gs-title:hover b { color: #0568CD; }
   .gs-webResult.gs-result a.gs-title:active,
   .gs-webResult.gs-result a.gs-title:active b,
   .gs-imageResult a.gs-title:active,
   .gs-imageResult a.gs-title:active b { color: #0568CD; }
   .gsc-cursor-page { color: #0568CD; }
   a.gsc-trailing-more-results:link { color: #0568CD; }
   .gs-webResult .gs-snippet,
   .gs-imageResult .gs-snippet,
   .gs-fileFormatType { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl,
   .gs-imageResult div.gs-visibleUrl { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { color: #5F6A73; }
   .gs-webResult div.gs-visibleUrl-short { display: none; }
   .gs-webResult div.gs-visibleUrl-long { display: block; }
   .gs-promotion div.gs-visibleUrl-short { display: none; }
   .gs-promotion div.gs-visibleUrl-long { display: block; }
   .gsc-cursor-box { border-color: #FFFFFF; }
   .gsc-results .gsc-cursor-box .gsc-cursor-page {
      border-color: #999999;
      background-color: #FFFFFF;
      color: #0568CD;
   }
   .gsc-results .gsc-cursor-box .gsc-cursor-current-page {
      border-color: #999999;
      background-color: #999999;
      color: #0568CD;
   }
   .gsc-webResult.gsc-result.gsc-promotion {
      border-color: #D2D6DC;
      background-color: #D0D1D4;
   }
   .gsc-completion-title { color: #0568CD; }
   .gsc-completion-snippet { color: #5F6A73; }
   .gs-promotion a.gs-title:link,
   .gs-promotion a.gs-title:link *,
   .gs-promotion .gs-snippet a:link { color: #0066CC; }
   .gs-promotion a.gs-title:visited,
   .gs-promotion a.gs-title:visited *,
   .gs-promotion .gs-snippet a:visited { color: #0066CC; }
   .gs-promotion a.gs-title:hover,
   .gs-promotion a.gs-title:hover *,
   .gs-promotion .gs-snippet a:hover { color: #0066CC; }
   .gs-promotion a.gs-title:active,
   .gs-promotion a.gs-title:active *,
   .gs-promotion .gs-snippet a:active { color: #0066CC; }
   .gs-promotion .gs-snippet,
   .gs-promotion .gs-title .gs-promotion-title-right,
   .gs-promotion .gs-title .gs-promotion-title-right *  { color: #333333; }
   .gs-promotion .gs-visibleUrl,
   .gs-promotion .gs-visibleUrl-short { color: #5F6A73; }
   </style>
</center>
</p>
&nbsp;

<div id="mainmenu">
<div class="text">

 <div class="tabs">
   <ul class="tablist">
   <li><a href="../index.html"><span>Home</span></a>
   <li><a href="../overview.html"><span>Overview</span></a>
   <li><a href="../html/index.html"><span>Class Documentation</span></a>
   <li><a href="../fformats.html"><span>File Formats</span></a>
   <li><a href="../tutorial.html"><span>Tutorial</span></a>
   <li class="current"><a href="../demos.html"><span>Demo Codes</span></a>
 </div>

 </div>
 </div>

&nbsp;
<p>
<h2>Fluid Dynamics Demo 2:<br> A 2-D incompressible CFD problem using
 triangles and a projection time integration method</h2>

<p><table border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="tiff2.html"><img src="../im/backward.gif" border="0"></a></td>
<td align="center" width="35"><a href="../demos.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="ls_demo1.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table>


&nbsp;&nbsp;
<h1>The main program</h1>

<p>
<SPAN class=TEXT>
We present an <span class=LOGO>OFELI</span> program that solves the
2-D time-dependent incompressible Navier-Stokes equations. For this
demo, we solve these equations by a time integration projection
method. Space discretisation is handled by a triangular finite element method.
</SPAN>

<ul type=square>
<li><SPAN class=TEXT>We start by including the classes for fluid dynamics. We also
use here a user defined class for prescibing data:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   #include "OFELI.h"
   #include "Fluid.h"
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>Like for the previous example, we define an
instance of class <span class=VAR><a
href="../html/classOFELI_1_1IPF.html">IPF</a></span>
to handle project data. We also define as data the Reynolds number
<span class=VAR>Re</span>.

<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   IPF proj(argv[1]);
   int verbose = proj.getVerbose();
   Mesh mesh(proj.getMeshFile());
   theTimeStep = proj.getTimeStep();
   theFinalTime = proj.getMaxTime();
   int plot_flag = proj.getPlot();
   double tol = proj.getTolerance();
   double Re = proj.getDouble("Reynolds");
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>To store solution we define two files, for
velocity and pressure by using the class  <span class=VAR><a
href="../html/classOFELI_1_1IOField.html">IOField</a></span>. The
resulting velocity and pressure vectors will be stored in
corresponding files for postprocessing.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   IOField vff(proj.getMeshFile(),proj.getString("v_file"),mesh,IOField::OUT);
   IOField pff(proj.getMeshFile(),proj.getString("p_file"),mesh,IOField::OUT);
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>
In the present demo, we do not need declaring a matrix, this is done
in the equation class. For this we shall use a constructor that uses a
reference to the <span class=VAR><a href="../html/classOFELI_1_1Mesh.html">Mesh</a></span>
instance. We also transmit to the created instance necessary parameters:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Vect&lt;double&gt; u(mesh,"Velocity",0), p(mesh,"Pressure",0,1);
   TINS2DT3B eq(mesh,u,p,theTimeStep,Re);
   eq.setVerbose(verbose);
   eq.setTolerance(tol);
</font></pre>
</td></tr></table>
</SPAN></p>

We have next to declare vectors for initial conditions, boundary
conditions, ... To initialize these vectors, the class
<span class=VAR><a href="../html/classOFELI_1_1Prescription.html">Prescription</a></span>
can be used. We note that these conditions are read in the same file
as the project file. For instance to assign initial conditions, we can
retrieve this information in this file, then transmit it to the
equation by the member function <span class=VAR>setInput</span>:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   Vect&lt;double&gt; bc(mesh), bf(mesh), sf(mesh);
   Prescription pr(mesh,proj.getDataFile());
   pr.get(INITIAL_FIELD,u);
   eq.setInput(INITIAL_FIELD,u);
</font></pre>
</td></tr></table>
</SPAN></p>

<li><SPAN class=TEXT>
We are now ready to start computations, <i>i.e.</i> looping over time
steps.
The procedure here is simple since everything is already programmed in
the class <span class=VAR><a href="../html/classOFELI_1_1TINS2.html">TINS2</a></span>.
We have only to assign
necessary data at each time step and then run the step.</p>

For each datum, we use the function <span class=VAR>get</span> to
obtain from the <span class=VAR><a href="../html/classOFELI_1_1Prescription.html">Prescription</a></span>
instance the vector, and then the
function <span class=VAR>set</span> to transmit to the
<span class=VAR><a
href="../html/classOFELI_1_1TINS2.html">TINS2</a></span> instance the
vector.
We may also note that at each time step the vectors <span
class=VAR>u</span> and <span class=VAR>p</span> contain respectively
the velocity and pressure for the current time step, so we can save
them
in appropriate files.
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>   TimeLoop {
      b = 0;
      pr.get(BOUNDARY_CONDITION,bc,theTime);
      eq.setInput(BOUNDARY_CONDITION,bc);
      pr.get(BODY_FORCE,bf,theTime);
      eq.setInput(BODY_FORCE,bf);
      pr.get(TRACTION,sf,theTime);
      eq.setInput(TRACTION,sf);
      eq.runOneTimeStep();
      if (plot_flag > 0 && theStep%plot_flag==0) {
         p.setTime(theTime); u.setTime(theTime);
         vff.put(u); pff.put(p);
      }
</font></pre>
</td></tr></table>
</SPAN>
</font></pre>
</td></tr></table>
</SPAN></p>
</ul>


&nbsp;&nbsp;
<h1>An example</h1>

<SPAN class=TEXT>
Let us run this program with the data presented in the following project file:
<p><table bgcolor="#e0f8f7" border="1" frame=box rules=none width=700>
<tr><td>
<pre><font color="blue" size=3>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
&lt;OFELI_File&gt;
&lt;info&gt;
   &lt;title&gt;&lt;/title&gt;
   &lt;date&gt;&lt;/date&gt;
   &lt;author&gt;&lt;/author&gt;
&lt;/info&gt;
&lt;Project name="cavity"&gt;
   &lt;time_step value="0.01"/&gt;
   &lt;max_time value="0.5"/&gt;
   &lt;verbose value="1"/&gt;
   &lt;plot value="10"/&gt;
   &lt;mesh_file value="cavity-30.m"/&gt;
   &lt;parameter label="Reynolds" value="1"/&gt;
   &lt;parameter label="v_file" value="cavity.v"/&gt;
   &lt;parameter label="p_file" value="cavity.p"/&gt;
&lt;/Project&gt;
&lt;Prescription&gt;
   &lt;BoundaryCondition code="2" dof="1"&gt;1&lt;/BoundaryCondition&gt;
&lt;/Prescription&gt;
&lt;/OFELI_File&gt;</font></pre>
</td></tr></table></p>

<p>
Note that we have also a section describing prescription data where a
boundary condition is given: We impose the value <span class=TT>1.0</span>
to the horizontal velocity <span class=VAR>dof="1"</span> for nodes
with a code equal to <span class=TT>2</span>.
All other data that are not given are by default set to  <span class=TT>0</span>.

<p><table align="center" border="2" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="35"><a href="tiff2.html"><img src="../im/backward.gif" border="0"></a></td>
<td align="center" width="35"><a href="../demos.html"><img src="../im/top.gif" border="0"></a></td>
<td align="center" width="35"><a href="ls_demo1.html"><img src="../im/forward.gif" border="0"></a></td>
</tr>
</table>

&nbsp;
<div id="foot_bar">
        Copyright &copy; 1998-2013 Rachid Touzani&nbsp;
</div>

</body>
</html>
